package com.bua.control;

import com.bua.toothfactory.R;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class ImageCheckBox extends LinearLayout {

	public boolean isChecked=false;
	private Bitmap image;
	private String title="";
	private Context mContext=null;
	
	private ImageView imageView=null;
	private CheckBox tvCheckBox=null;
//	@Override
//	public void draw(Canvas canvas) {
//		// TODO Auto-generated method stub
//		super.draw(canvas);
//	}
	
	private void init()
	{
		image=BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
		imageView=new ImageView(mContext);
		imageView.setImageBitmap(image);
		this.addView(imageView);
		title="CheckBox";
		//tvCheckBox=new CheckBox(mContext);
		LayoutInflater inflater = (LayoutInflater)mContext.getSystemService( Context.LAYOUT_INFLATER_SERVICE);
		tvCheckBox = (CheckBox) inflater.inflate(R.layout.image_check_box, null);
		tvCheckBox.setChecked(isChecked);
		tvCheckBox.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13.0f);
		tvCheckBox.setText(title);
		tvCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(CompoundButton buttonView, boolean IsChecked) {
				// TODO Auto-generated method stub
				isChecked=IsChecked;
			}
		});
		this.addView(tvCheckBox);
	}
	public ImageCheckBox(Context context) {
		super(context);
		this.setOrientation(VERTICAL);
		mContext=context;
		// TODO Auto-generated constructor stub
		init();
	}
	public ImageCheckBox(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.setOrientation(VERTICAL);
		mContext=context;
		init();
	}

	public void setImage(Bitmap bm)
	{
		imageView.setImageBitmap(bm);
	}
	
	
}
